package log;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * @author qhy
 * @version 1.0.0
 * @ClassName WriteToLog
 * @Description 写入日志的类
 * @Date 2017/7/5 17:51
 */
public class WriteToLog {
    private static Logger logger = null;
    static{
        String filePath = System.getProperty("user.dir") + "/log4j.properties";
        logger = Logger.getLogger("OperateLog");
        PropertyConfigurator.configure(filePath);
    }

    public static void write(String things){
        synchronized (logger) {
            logger.info(things);
        }
    }

    public static void main(String[] args){
        System.out.println(System.getProperty("user.dir"));
        WriteToLog.write("就是这样子的");
        WriteToLog.write("哈哈哈哈哈哈");
    }
}
